
<%@ page import="coe.pumbaa.User" %>
<% def stringManagerService = application.getAttribute("org.codehaus.groovy.grails.APPLICATION_CONTEXT").getBean("stringManagerService") %>
<% def springSecurityService = application.getAttribute("org.codehaus.groovy.grails.APPLICATION_CONTEXT").getBean("springSecurityService") %>
<html>
  <head>
    <meta name="layout" content="PumbaaLayout">
  <g:set var="entityName" value="${message(code: 'user.label', default: 'User')}" />
  <title>User Manager</title>
</head>
<body>
  <section id="main" class="column">
    <article class="module width_full">
      <header><h3>User requests</h3></header>
      <table class="tablesorter" cellspacing="0">
        <thead> 
          <tr>  
            <th>Email</th> 
            <th>First name</th> 
            <th>List name</th>
            <th>Display name</th>
            <th>Role</th>
            <th>Vote</th>
            <th style="width: 10%;">Actions</th> 
          </tr> 
        </thead>
        <tbody>
        <g:each in="${userRequestList}" var="userInstance">
          <tr>
            
            <td>${fieldValue(bean: userInstance, field: "email")}</td>

            <td>${fieldValue(bean: userInstance, field: "fname")}</td>
            
            <td>${fieldValue(bean: userInstance, field: "lname")}</td>
            
            <td>${fieldValue(bean: userInstance, field: "displayName")}</td>
            
            <td>${userInstance.role.type}</td>
            
            <td>${stringManagerService.countMemberInString(userInstance.voter)}</td>

            <td>
            <g:if test="${!stringManagerService.checkObjectInString(springSecurityService?.currentUser,userInstance.voter)}">
            <g:link action="accept" id="${userInstance.id}"><input type="image" src="${resource(dir: 'images', file: 'icn_alert_success.png')}" title="accept"></g:link>
            <g:if test="${session.user?.role?.level <= 0}">
              <g:link action="reject" id="${userInstance.id}"><input type="image" src="${resource(dir: 'images', file: 'icn_alert_error.png')}" title="reject" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');"></g:link>
            </g:if>
            </g:if>
            </td>
          
          </tr>
        </g:each>
        </tbody>
      </table>
      <footer>
        <div class="pagination">
          <h4><g:paginate total="${userRequestTotal}" /></h4>
        </div>
      </footer>
    </article>
    <div class="spacer"></div>
  </section>
</body>
</html>